package de.hauschild.gmltracer.gml.impl.value.geometry;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.real.RealToken;
import de.hauschild.gmltracer.tracer.Shape;

public class RotateXToken extends AbstractToken {

  @SuppressWarnings("unchecked")
  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final RealToken rotate = tokenStack.pop(RealToken.class);
    final ShapeToken<? extends Shape> shape = tokenStack.pop(ShapeToken.class);

    shape.getValue().rotateX(rotate.getValue());

    tokenStack.push(shape);
  }

  @Override
  public String toString() {
    return "rotatex";
  }
}
